Page({

  /**
   * 页面的初始数据
   */
  data: {
    
  },
  selectCity:function(e){
    // console.log(this.data.flag)
    // console.log(e.target.dataset.value)
    if(this.data.flag=='start'){
      this.setData({
        startCityId: e.target.dataset.value.id,
        startCityName: e.target.dataset.value.name
      })
    }
    if(this.data.flag=='end'){
      this.setData({
        endCityId: e.target.dataset.value.id,
        endCityName: e.target.dataset.value.name
      })
    }
    wx.navigateTo({
      url: '../order/order?startTime=' + this.data.startTime + '&endTime=' + this.data.endTime + '&day=' + this.data.day + '&startHour=' + this.data.startHour + '&endHour=' + this.data.endHour + '&productId=' + this.data.productId + '&startCityId=' + this.data.startCityId + '&endCityId=' + this.data.endCityId + '&startCityName=' + this.data.startCityName + '&endCityName=' + this.data.endCityName+'&sendType=' + this.data.sendType + '&sendName=' + this.data.sendName + '&sendMobile=' + this.data.sendMobile + '&sendAddress=' + this.data.sendAddress + '&receiveType=' + this.data.receiveType + '&receiveName=' + this.data.receiveName + '&receiveMobile=' + this.data.receiveMobile + '&receiveAddress=' + this.data.receiveAddress + '&type=' + this.data.type
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      productId: options.productId,
      startTime: options.startTime,
      startHour: options.startHour,
      endTime: options.endTime,
      endHour: options.endHour,
      day: options.day,
      startCityId: options.startCityId,
      startCityName: options.startCityName,
      endCityId: options.endCityId,
      endCityName: options.endCityName,
      sendType: options.sendType ? options.sendType : '',
      sendName: options.sendName ? options.sendName : '',
      sendMobile: options.sendMobile ? options.sendMobile : '',
      sendAddress: options.sendAddress ? options.sendAddress : '',
      receiveType: options.receiveType ? options.receiveType : '',
      receiveName: options.receiveName ? options.receiveName : '',
      receiveMobile: options.receiveMobile ? options.receiveMobile : '',
      receiveAddress: options.receiveAddress ? options.receiveAddress : '',
      flag:options.flag,
      type:options.type
    })
    this.loadCity()
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
    
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
    
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    return {
      title: '琼崖租车',
      path: '/pages/index/index'
    }
  },

  loadCity:function(){
    let that = this
    wx.request({
      url: 'https://small.qiongyazuche.com/sunday/web/area/getCity',
      method: 'POST',
      header: {
        "Content-Type": "application/x-www-form-urlencoded"
      },
      data: {
        'provinceId': 21
      },
      success: function (res) {
        that.setData({
          citys:res.data
        })
      }
    })
  }
  
})